package com.ruoyi.wechat.api;


import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;

import com.ruoyi.wechat.domain.CampSite;
import com.ruoyi.wechat.service.ICampSiteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(value = "微信小程序API-营地营位管理", tags = {"微信小程序API-营地营位管理"})
@RestController
@RequestMapping("/wechat/campsite")
public class WxCampsiteController extends BaseController {
    @Autowired
    private ICampSiteService campsiteService;

    /**
     * 按条件搜索营位列表
     * @param campsite 营位信息
     * @return 列表
     */
    @ApiOperation(value = "按条件搜索营位列表", response = CampSite.class)
    @GetMapping("/wxlist")
    public AjaxResult list(CampSite campsite) {
        List<CampSite> list  = campsiteService.selectCampSiteList(campsite);
        return success(list);
    }
    /**
     * 获取营地营位详细信息
     */
    @ApiOperation(value = "根据营位id获取详细信息", response = CampSite.class)
    @ApiParam(required = true, value = "直接传入id")
    @GetMapping(value = "/wxgetInfo/{campsiteId}")
    public AjaxResult getInfo(@PathVariable("campsiteId") String campsiteId)
    {
        return success(campsiteService.selectCampSiteByCampsiteId(campsiteId));
    }

    /**
     * 新增营地营位
     */
    @ApiOperation(value = "新增营地营位")
    @PostMapping("wxadd")
    public AjaxResult add(@RequestBody CampSite campsites)
    {
        return toAjax(campsiteService.insertCampSite(campsites));
    }


    /**
     * 修改营地营位
     */
    @ApiOperation(value = "修改营地营位")
    @PutMapping("wxupdate")
    public AjaxResult edit(@RequestBody CampSite campsite)
    {
        return toAjax(campsiteService.updateCampSite(campsite));
    }

    /**
     * 删除营地营位
     */
    @ApiOperation(value = "删除营地营位")
    @DeleteMapping("/delete/{campsiteId}")
    public AjaxResult remove(@PathVariable("campsiteId") String campsiteId)
    {
        return toAjax(campsiteService.deleteCampSiteByCampsiteId(campsiteId));
    }
}

